// 执行终端命令相关的代码
const { spawn } = require("child_process")

const commandSpawn = (...args) => {

  return new Promise((resolve, reject) => {
    // 获取子进程
    const childProcess = spawn(...args)

    // 打印执行过程信息
    childProcess.stdout.pipe(process.stdout)
    childProcess.stderr.pipe(process.stderr)

    childProcess.on("close", () => {
      resolve()
    })
  })

}

module.exports = {
  commandSpawn
}

